import { useCookieState } from 'ahooks'
import { Outlet, Navigate } from 'react-router-dom'

export function Protected() {
  const [accessCode] = useCookieState('accessCode')
  const isLogged = accessCode?.length !== undefined

  return isLogged ? <Outlet /> : <Navigate to='/login' replace />
}
